import requests
from config import url, headers_web


class CourseDimensionMaterial:
    def __init__(self):
        self.url = url
        self.headers_web = headers_web

    @classmethod
    def post_course_dimension_file_download(cls, url: str, params=None, body=None, headers=headers_web):
        """
        @Summary: 下载课程材料维度文件接口
        @Description: 1.云课堂管理端-本科教学评估使用
        :param headers: {
                          "Content-Type":"application/json",
                          "X-Requested-With":"XMLHttpRequest",
                          "User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64)
                          AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36"
                        }
        :param url: http://192.168.1.32:8080
        :param params: {validCode: string #验证码（&signKey=123123）}
        :param body: {
                      "auditStatus": integer, #审核状态：0-未审核，1-审核通过，2-审核不通过
                      "collegeId": "string", #部门id
                      "isTeachingQualityEvaluationAdmin": boolean, #是否校管理员 0：否；1：是
                      "operatorId": "string", #操作人ID
                      "courseNameOrNo": "string", #课程名称或工号，支持多个 用空格隔开
                      "upload": boolean, #是否上传
                      "page": integer, #当前页
                      "pageSize": integer, #每页数量
                      "typeCodes": "string", #类型编号s,多个使用逗号隔开（
                                              教学大纲：syllabus，教学日历：teachingCalendar，
                                              教案：teachingPlan，教学案例：teachingCases，试卷分析：testPaperAnalysis）
                    }
        :return:
        """
        url_path = url + f"/teachingqualityevaluationapi/v1/coursedimensionmaterial/file/download"
        r = requests.post(url=url_path, headers=headers, params=params, json=body)
        return r

    @classmethod
    def post_course_dimension_page(cls, url: str, params=None, body=None, headers=headers_web):
        """
        @Summary: 获取课程料列表接口
        @Description: 1.云课堂管理端-本科专业评估使用
        :param url: http://192.168.1.32:8080
        :param params: {validCode: string #验证码（&signKey=123123）}
        :param body: {
                      "auditStatus": integer, #审核状态：0-未审核，1-审核通过，2-审核不通过
                      "collegeId": "string", #学院ID
                      "courseNameOrNo": "string", #课程名称或工号，支持多个 用空格隔开
                      "isTeachingQualityEvaluationAdmin": boolean, #是否校管理员 0：否；1：是
                      "isUpload": boolean, #是否上传：0-否，1-是
                      "majorName": "string", #专业名称
                      "operatorId": "string", #操作人ID
                      "page": integer, #当前页
                      "pageSize": integer, #每页数量
                      "sortName": "string", #排序字段 uploadTime:上传时间，不传或者其他值使用默认排序
                      "sortRule": "string", #排序规则：asc：升序；desc：降序
                       "typeCodes": "string" #类型编号s,多个使用逗号隔开
                    }
        :param headers:{
                      "Content-Type":"application/json",
                      "X-Requested-With":"XMLHttpRequest",
                      "User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64)
                      AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36"
                    }
        :return:{
                "materialResourceList": [
                            {
                              "assessmentMethod": "string", #考核方式
                              "auditStatus": integer, #审核状态：0-未审核，1-审核通过，2-审核不通过
                              "classHour": integer, #学时
                              "classScore": number, #学分
                              "collegeAdminIds": "string", #院管理员ids，多个用;拼接
                              "collegeAdminNames": "string", #院管理员姓名，多个用;拼接
                              "collegeAdminNos": "string", #院管理员工号，多个用;拼接
                              "collegeCode": "string", #学院编号
                              "collegeId": "string", #学院ID
                              "collegeName": "string", #学院名称
                              "courseCode": "string", #课程代码
                              "courseLeader": "string", #课程负责人名称，多个用；拼接
                              "courseLeaderIds": "string", #课程负责人id，多个用；拼接
                              "courseLeaderNos": "string", #课程负责人工号，多个用;拼接
                              "courseName": "string", #课程名称
                              "courseNatureName": "string", #课程性质名称
                              "courseTypeName": "string", #课程类型名称
                              "dean": "string", #系主任姓名，多个用;拼接
                              "deanIds": "string", #系主任ids，多个用;拼接
                              "deanNos": "string", #系主任工号，多个用;拼接
                              "id": "string", #课程资料ID
                              "isAllowAudit": boolean, #是否允许审核
                              "isAllowUpload": boolean, #是否允许上传
                              "isUpload": boolean, #是否上传 0-否，1-是
                              "materialTypeResourceList": [
                                {
                                  "isRequired": boolean, #是否必填
                                  "typeFileList": [
                                    {
                                      "fileDisplayName": "string", #文件显示名称
                                      "filePath": "string", #文件路径
                                      "fileRealName": "string", #文件存储名称
                                      "fileSize": integer, #文件大小
                                      "fileType": "string", #文件类型
                                      "innerUrl": "string", #内网ip
                                      "materialFileId": "string", #id
                                      "outerUrl": "string", #外网ip
                                      "termList": [
                                                    {
                                                      "schoolYear": "string", #学年
                                                      "term": integer, # 学期
                                                      "termId": "string", #学年学期ID
                                                      "termName": "string" #学年名称
                                                    }
                                                  ]
                                    }
                                  ],
                                  "typeId": "string", #类型ID
                                  "typeName": "string" #类型名称
                                }
                              ],
                              "operatorId": "string", #操作人Id
                              "operatorName": "string", #操作人姓名
                              "operatorNo": "string", #操作人工号
                              "teachWay": "string", #授课方式
                              "teachingMaterialType": "string", #教材类型
                              "teachingMaterialUsage": "string", #教材使用情况
                              "uploadTime": "string" #上传时间
                            }
                          ],
              "page": integer, #当前页
              "pageSize": integer, #每页个数
              "total": integer #总页数
                        }
        """
        url_path = url + "/teachingqualityevaluationapi/v1/coursedimensionmaterial/page"
        r = requests.post(url=url_path, headers=headers, params=params, json=body)
        return r

    @classmethod
    def get_course_dimension_flow(cls, url: str, headers=headers_web, params=None, params_path=None):
        """
        @Summary: 获取课程维度资料流程接口
        @Description: 1、云课堂管理端指标维度资料调用
        :param headers:{
                          "Content-Type":"application/json",
                          "X-Requested-With":"XMLHttpRequest",
                          "User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64)
                          AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36"
                        }
        :param url: http://192.168.1.32:8080
        :param params: {validCode: "string" #验证码（id={}&signKey=123123）}
        :param params_path: "string" # 课程资料ID
        :return: [{
                    "flowName": "string", #流程名称
                    "flowOperatorId": "string", #流程操作人ID
                    "flowOperatorName": "string", #流程操作人姓名
                    "flowOperatorNo": "string", #流程操作人工号
                    "flowOperatorTypeName": "string", #流程操作人类型名称
                    "id": "string" #专业资料ID
                  }]
        """
        url_path = url + f"/teachingqualityevaluationapi/v1/coursedimensionmaterial/{params_path}/flow"
        r = requests.get(url=url_path, headers=headers, params=params)
        return r